package com.tech.view.component.border;

import javax.swing.border.AbstractBorder;
import java.awt.*;

public class RoundBorder extends AbstractBorder {
	private Color color;
	private int arcSize;
	public RoundBorder(Color color,int arcSize) {
		this.color = color;
		this.arcSize =arcSize;
	}

	public RoundBorder() {
		this.color = Color.BLACK;
	}

	// 实现Border（父类）方法
	@Override
	public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
		Graphics2D g2 = (Graphics2D) g;
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		g2.setColor(color);
		g2.drawRoundRect(1, 1, c.getWidth() - 2, c.getHeight() - 2, arcSize, arcSize);
	}
}
